package com.edu.bean;

import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.Range;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.Email;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.Past;
import java.util.Date;

public class User {

    private int userId;

    @NotEmpty(message = "用户名必填")
    @Length(min = 6,max=10,message = "用户名长度必须在6-10位之间")
    private String username;

    @NotEmpty(message = "密码必填")
    @Length(min = 6,max=10,message = "密码长度必须在6-10位之间")
    private String password;

    @Range(min=1,max=150,message = "年龄应该在0-120之间")
    private int userAge;

    @Past(message = "你不可能出生在未来")
    @DateTimeFormat(pattern = "yyyy-MM-dd",fallbackPatterns = {"yyyy/MM/dd","yyyy\\MM\\dd","yyyy年MM月dd日"})
    private Date birthDay;

    @Email(message = "必须是邮箱格式")
    private String email;

    private String userSex;

    public String getUserSex() {
        return userSex;
    }

    public void setUserSex(String userSex) {
        this.userSex = userSex;
    }

    public int getUserId() {
        return userId;
    }

    public void setUserId(int userId) {
        this.userId = userId;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public int getUserAge() {
        return userAge;
    }

    public void setUserAge(int userAge) {
        this.userAge = userAge;
    }

    public Date getBirthDay() {
        return birthDay;
    }

    public void setBirthDay(Date birthDay) {
        this.birthDay = birthDay;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public User() {
    }

    public User(String username, String password, int userAge, Date birthDay, String email, String userSex) {
        this.username = username;
        this.password = password;
        this.userAge = userAge;
        this.birthDay = birthDay;
        this.email = email;
        this.userSex = userSex;
    }

    @Override
    public String toString() {
        return "User{" +
                "userId=" + userId +
                ", username='" + username + '\'' +
                ", password='" + password + '\'' +
                ", userAge=" + userAge +
                ", birthDay=" + birthDay +
                ", email='" + email + '\'' +
                '}';
    }
}
